package com.ctshk.rpc.order.goods.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.rpc.order.goods.entity.CommodityAttribute;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 商品属性表 Mapper 接口
 * </p>
 *
 * @author 姜斌文
 * @since 2021-04-13
 */
public interface CommodityAttributeMapper extends BaseMapper<CommodityAttribute> {

    @Select("SELECT t.id, t.commodity_id, t.specifications_type, t.distribution_commission_settings, t.currency_id, t.currency_name, t.exchange_rate, t.gmt_create, t.create_id, t.gmt_modified, t.modified_id, t.is_deleted "
            + "FROM `ctshk-goods`.t_commodity_attribute t "
            + "WHERE t.commodity_id = #{commodityId} AND t.is_deleted = 0")
    CommodityAttribute findCommodityAttributeByCommodityId(@Param("commodityId") Long commodityId);

    /**
     * 根据商品id查询属性
     * @param id
     * @return
     */
    @Select({
            "SELECT id,commodity_id,specifications_type,distribution_commission_settings,currency_id,currency_name,exchange_rate,create_id,modified_id,is_deleted,gmt_create,gmt_modified " +
                    "FROM `ctshk-goods`.t_commodity_attribute " +
                    "WHERE (commodity_id = #{id})"
    })
    CommodityAttribute selectAttributeByCommodityId(@Param("id") Long id);
}
